﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Food
{
	class WeekOrder
	{
		private XmlDocument _doc;
		private string _fileName;

		public Dictionary<DayOfWeek, DayOrder> DayOrders;

		public WeekOrder(User user, Week week)
		{
			_doc = new XmlDocument();

			_fileName = Config.WeeksFolderPath + @"\" + week.FolderName + @"\" + Config.OrdersFolderName + @"\" + user.FileName;

			_doc.Load(_fileName);

			DayOrders = new Dictionary<DayOfWeek, DayOrder>();
		}

		public void AddDayOrder(DayOfWeek dayOfWeek)
		{
			DayOrder dayOrder;

			if (DayOrders.ContainsKey(dayOfWeek))
			{
				dayOrder = DayOrders[dayOfWeek];
			}
			else
			{
				dayOrder = new DayOrder((XmlNode)_doc.CreateElement("day"));
			}
		}

		public void Save()
		{
			_doc.Save(_fileName);
		}
	}
}
